package com.roper.yygh.cmn.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.roper.yygh.cmn.mapper.DictMapper;
import com.roper.yygh.model.cmn.Dict;
import com.roper.yygh.vo.cmn.DictEeVo;
import org.springframework.beans.BeanUtils;

/**
 * Description:
 * Date:      2021/7/5 22:17
 * author:    LPH
 * version:   V1.0
 */
public class DictListener extends AnalysisEventListener<DictEeVo> {

    private DictMapper dictMapper;

    public DictListener(DictMapper dictMapper) {
        this.dictMapper = dictMapper;
    }

    // 一行一行的读取，从第二行开始读
    @Override
    public void invoke(DictEeVo dictEeVo, AnalysisContext analysisContext) {
        // 调用方法添加数据库
        Dict dict = new Dict();
        // 把前者copy给后者
        BeanUtils.copyProperties(dictEeVo, dict);
        dictMapper.insert(dict);
    }


    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
